/**
 * 主样式文件
 * 
 * 包含整个应用的基础样式和布局
 */

/* 重置样式 */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body, html {
  width: 100%;
  height: 100%;
  font-family: 'Arial', sans-serif;
  overflow: hidden;
}

/* 主容器样式 */
#app {
  width: 100%;
  height: 100%;
  display: flex;
  flex-direction: column;
}

/* 顶部导航栏 */
.top-nav {
  height: 60px;
  background-color: #2c3e50;
  color: white;
  display: flex;
  align-items: center;
  padding: 0 20px;
  box-shadow: 0 2px 5px rgba(0, 0, 0, 0.1);
  z-index: 100;
}

.top-nav h1 {
  font-size: 1.5rem;
  margin-right: 30px;
}

.top-nav .nav-links {
  display: flex;
  gap: 20px;
}

.top-nav .nav-links a {
  color: white;
  text-decoration: none;
  padding: 5px 10px;
  border-radius: 4px;
  transition: background-color 0.3s;
}

.top-nav .nav-links a:hover,
.top-nav .nav-links a.active {
  background-color: rgba(255, 255, 255, 0.2);
}

/* 主内容区 */
.main-content {
  flex: 1;
  display: flex;
  position: relative;
  overflow: hidden; /* 防止内容溢出 */
}

/* 侧边导航 */
.side-nav {
  width: 250px;
  min-width: 250px; /* 确保侧边栏不会被挤压 */
  background-color: #f8f9fa;
  overflow-y: auto;
  padding: 20px 0;
  box-shadow: 2px 0 5px rgba(0, 0, 0, 0.05);
  z-index: 90;
}

.side-nav h2 {
  padding: 0 20px 10px;
  font-size: 1.2rem;
  color: #333;
  border-bottom: 1px solid #eee;
  margin-bottom: 10px;
}

.demo-list {
  list-style: none;
}

.demo-item {
  padding: 10px 20px;
  cursor: pointer;
  transition: background-color 0.2s;
}

.demo-item:hover {
  background-color: #e9ecef;
}

.demo-item.active {
  background-color: #e9ecef;
  border-left: 4px solid #007bff;
}

.demo-item h3 {
  font-size: 1rem;
  margin-bottom: 5px;
  color: #333;
}

.demo-item p {
  font-size: 0.85rem;
  color: #666;
}

/* Cesium 容器 */
.cesium-container {
  width: 100%;
  height: 100%;
  position: relative;
}

/* 案例内容 */
.demo-content {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden; /* 防止内容溢出 */
  width: calc(100% - 250px); /* 减去侧边栏宽度 */
}

.demo-header {
  padding: 15px 20px;
  background-color: #f8f9fa;
  border-bottom: 1px solid #eee;
}

.demo-header h2 {
  font-size: 1.5rem;
  margin-bottom: 5px;
}

.demo-header p {
  color: #666;
}

.demo-viewer {
  flex: 1;
  position: relative;
  width: 100%;
  height: 100%; /* 修改为 100%，不再减去头部高度 */
}

/* 工具面板 */
.tools-panel {
  position: absolute;
  top: 10px;
  right: 10px;
  background-color: rgba(255, 255, 255, 0.8);
  border-radius: 4px;
  padding: 10px;
  box-shadow: 0 2px 5px rgba(0, 0, 0, 0.1);
  z-index: 1000;
}

.tools-panel button {
  display: block;
  width: 100%;
  padding: 8px 12px;
  margin-bottom: 5px;
  background-color: #007bff;
  color: white;
  border: none;
  border-radius: 4px;
  cursor: pointer;
  transition: background-color 0.2s;
}

.tools-panel button:hover {
  background-color: #0069d9;
}

.tools-panel button:last-child {
  margin-bottom: 0;
}

/* 首页样式 */
.home-page {
  flex: 1;
  padding: 30px;
  overflow-y: auto;
}

.demo-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 20px;
  margin-top: 20px;
}

.demo-card {
  border: 1px solid #eee;
  border-radius: 8px;
  overflow: hidden;
  transition: transform 0.2s, box-shadow 0.2s;
}

.demo-card:hover {
  transform: translateY(-5px);
  box-shadow: 0 5px 15px rgba(0, 0, 0, 0.1);
}

.demo-card img {
  width: 100%;
  height: 180px;
  object-fit: cover;
}

.demo-card-content {
  padding: 15px;
}

.demo-card h3 {
  margin-bottom: 10px;
  font-size: 1.2rem;
}

.demo-card p {
  color: #666;
  margin-bottom: 15px;
  font-size: 0.9rem;
}

.demo-card button {
  padding: 8px 15px;
  background-color: #007bff;
  color: white;
  border: none;
  border-radius: 4px;
  cursor: pointer;
  transition: background-color 0.2s;
}

.demo-card button:hover {
  background-color: #0069d9;
}

/* 响应式设计 */
@media (max-width: 768px) {
  .side-nav {
    position: absolute;
    left: -250px;
    height: 100%;
    transition: left 0.3s;
  }
  
  .side-nav.open {
    left: 0;
  }
  
  .menu-toggle {
    display: block;
  }
}

/* 加载动画 */
.loader {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 50px;
  height: 50px;
  border: 5px solid #f3f3f3;
  border-top: 5px solid #3498db;
  border-radius: 50%;
  animation: spin 1s linear infinite;
}

@keyframes spin {
  0% { transform: translate(-50%, -50%) rotate(0deg); }
  100% { transform: translate(-50%, -50%) rotate(360deg); }
}
